﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.DAL.DocumentCenter;
using Microsoft.SharePoint;
using MS.InformationManagement.Core.Support;
using MS.InformationManagement.Support;
using MS.InformationManagement.BLL;


namespace MS.InformationManagement.Presenter.InclurRadicadoRecord
{
    public class IncluirRadicadoRecordPresenter : BasePresenter<IIncluirRadicadoRecordView>
    {

        #region Constructors

        public IncluirRadicadoRecordPresenter(IIncluirRadicadoRecordView view) : base(view) { } 

        #endregion

        #region Public Methods

        public void Incluir()
        {

            BLL.ExpedienteViewer.ExpedienteViewer expV = new BLL.ExpedienteViewer.ExpedienteViewer();
            expV.Incluir(View.ExpedienteId, View.RadicadoId);
            //SPList list = SPContext.Current.Web.Lists[new Guid(View.CurrentListId)];
            //SPListItem targetRad = list.GetItemById(Convert.ToInt32( View.RadicadoId));
            //SPContext.Current.Web.AllowUnsafeUpdates = true;
            //targetRad[MS.InformationManagement.Support.Constants.CustomSiteColumns.FIELD_DOCUMENT_FILED] = true;
            //targetRad.Update();
            //SPContext.Current.Web.AllowUnsafeUpdates = false;
            //using (var dc = new DCDocumentCenterDataContext(SPContext.Current.Web.Url))
            //{
            //    var currentRadicado = (from rad in dc.GetList<Radicado>(currentListName).ScopeToFolder("", true)
            //                           where rad.NoRadicado == View.RadicadoId
            //                           select rad).FirstOrDefault();
            //    if (currentRadicado == null)
            //        throw new Exception("El radicado seleccionado no se encontro");
            //    currentRadicado.Archivado = true;
            //    dc.SubmitChanges();
            //}
            View.close();
        }


        #endregion

        

    }
}
